<cfcomponent extends="queries">

	<!---Need to call BASE functions--->
    <cfset BASE = CreateObject("component", "base") />
    
    
    <!--- Create Stored Procedure to create HR Record for employee's emergency contacts --->
    <cffunction name="funcCreateEmployeeEmergencyContact" returntype="any">
    	<cfargument default="-1" name="QUERIES" required="yes"/>
        <cfargument default="-1" name="PASSEDIN" required="yes"/>
        <cfargument default="-1" name="Thread" required="yes"/>
		
        <Cfset retVal = {} />
        <cfset retVal.HRResult = "" />
        
        <cfset ContactOrder = 1>
        
        <cfloop query="ARGUMENTS.QUERIES.GetEmpECInfo"> 
            
            <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_CreationStep3_EmergencyContact">  
                <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.Thread.NewHRPersonIDNo#" />, <!--- @pintPersonIDNo --->
                <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.ActStartDate#" />, <!--- @pdteDOH --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#First#" />, <!--- @pstrFirst --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#Last#" />, <!--- @pstrLast --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#RelationID#" />, <!--- @pintRelationID --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#ContactOrder#" />,<!--- @pintContactOrder --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.EMP_ADDRESS_TYPE#" />, <!---@pintAddressTypeID --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#Address1#" />, <!--- @pstrAddress1 --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#Address2#" />, <!---@pstrAddress2 --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#City#" />, <!--- @pstrCity --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#State#" />, <!--- @pintStateID --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#Zip#" />, <!--- @pstrZIP --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#PASSEDIN.USA#" />, <!--- @pintUSAID --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#BASE.DisplayPhone(HomePhone)#" />, <!--- @pstrHomePhone --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#BASE.DisplayPhone(CellPhone)#" />,<!--- @pstrCellPhone --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#BASE.DisplayPhone(WorkPhone)#" />,<!--- @pstrWorkPhone --->
                <cfprocparam cfsqltype="cf_sql_varchar" value="#WorkPhoneExt#" />,<!--- @pstrWorkExt --->
                <cfprocparam cfsqltype="cf_sql_integer" value="#PhonePrimaryID#" /> <!---@pintPrimaryPhoneID --->
                <cfprocresult name="ErrorCheck" resultset="1">
        	</cfstoredproc>
            
            <cfif ErrorCheck.Error NEQ 0>
				<cfset retVal.HRResult &= "Error creating Emergency Contact record for #First# #Last#.  
                    Please check the record in the Kronos HR tools and fix manually if necessary.<BR/>">
                <cfset retVal.Result = ErrorCheck.Error>
            </cfif>
            
 			<cfset ContactOrder += 1>
        </cfloop>

        <cfreturn retVal />
    </cffunction>
    <!--- Create Stored Procedure to create HR Record for employee's emergency contacts --->
    
    
    
    
    
    <!--- Create Stored Procedure to create HR Record for employee's address --->
    <cffunction name="funcCreateEmployeeAddressesPhones" returntype="any">
    	<cfargument default="-1" name="QUERIES" required="yes"/>
        <cfargument default="-1" name="PASSEDIN" required="yes"/>
        <cfargument default="-1" name="Thread" required="yes"/>
        
        <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_CreationStep2_AddressesPhones">  
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.Thread.NewHRPersonIDNo#" />, <!--- @pintPersonIDNo --->
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.ActStartDate#" />, <!--- @pdteDOH --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.EMP_ADDRESS_TYPE#" />, <!--- @pintAddressTypeID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Address1#" />, <!--- @pstrAddress1 --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Address2#" />, <!--- @pstrAddress2 --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.City#" />, <!--- @pstrCity --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.State#" />, <!--- @pintStateID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Zip#" />, <!--- @pstrZIP --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.USA#" />, <!--- @pintUSAID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.HomePhone#" />, <!--- @pstrHomePhone --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.CellPhone#" />, <!--- @pstrCellPhone --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.WorkPhone#" />, <!--- @pstrWorkPhone --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.WorkPhoneExt#" />, <!--- @pstrWorkExt --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.PhonePrimaryID#" /><!--- @pintPrimaryPhoneID --->
            <cfprocresult name="ErrorCheck" resultset="1">
        </cfstoredproc>

        <cfreturn ErrorCheck />
    </cffunction>
    <!--- Create Stored Procedure to create HR Record for employee's address --->
    
    
    
    
    
    <!--- Create Stored Procedure to create HR Record for employee --->
    <cffunction name="funcCreateEmployee" returntype="any">
    	<cfargument default="-1" name="QUERIES" required="yes"/>
        <cfargument default="-1" name="PASSEDIN" required="yes"/>
        <cfargument default="-1" name="FORM" required="yes"/>
        
        <cfset AnnualSalary = ARGUMENTS.QUERIES.GetEmpInfo.PayRate * ARGUMENTS.QUERIES.GetAF.AnnualizingFactor />
        
        <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_CreationStep1_CreateEmployee">  
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.DOB#"><!--- @pdteDOB --->
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.ActStartDate#"><!--- @pdteDOH --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.First#"><!--- @pstrFirst --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Last#"><!--- @pstrLast --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.PreferredName#"><!--- @pstrPreferred --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Middle#"><!--- @pstrMI --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.SSN#"><!--- @pstrSSN --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.MaritalStatusID#"><!--- @pintMaritalStatusID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.EthnicID#"><!--- @pintEthnicID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.GenderID#"><!--- @pintGenderID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.PositionID#"><!--- @pintPosID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PP_REASON_NEW_HIRE#"><!--- @pintPosReasonID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.SupervisorID#"><!--- @pintSupervisorID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PRIMARY_POS#"><!--- @pintPrimaryPos --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PROMOTION#"><!--- @pintPomotion --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.Exempt#"><!--- @pintExempt --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.SalaryHourlyID#"><!--- @pintSalaryHourlyID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.Seasonal#"><!--- @pintSeasonal --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.HoursPerWeek#"><!--- @pintHrsPerWk --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.WorkersCompID#"><!--- @pintWkrsCompID --->
            <cfprocparam cfsqltype='cf_sql_float' value="#ARGUMENTS.PASSEDIN.COMP_LOCATION_FACTOR#"><!--- @pfltCompLocationFactor --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ACTIVE#"><!--- @pintEmployeeStatusIDNo --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.FullTime#"><!--- @pintFullTime --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.I9_PENDING#"><!--- @pintI9PendingID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ORG_SCF#"><!--- @pintOrgCodeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.EmpCodeID#"><!--- @pintEmploymentCodeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.I9#"><!--- @pintI9OnFileID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ES_REASON_NEW_HIRE#"><!--- @pintEmploymentStatusReasonID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PS_REASON_NEW_HIRE#"><!--- @pintPayReasonID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.CompTypeID#"><!--- @pintCompTypeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.FrequencyID#"><!--- @pintFrequencyID --->
            <cfprocparam cfsqltype="cf_sql_float" value="#ARGUMENTS.QUERIES.GetEmpInfo.PayRate#"><!--- @pfltPayRate --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetAF.AnnualizingFactor#"><!--- @pintAnnualizingFactor --->
            <cfprocparam cfsqltype="cf_sql_float" value="#AnnualSalary#"><!--- @pfltAnnualSalary --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.BASEPAY#"><!--- @pintBasePay --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.DOLLARS#"><!--- @pintCurrencyID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.NewUserID#"><!--- @pstrNewUserID --->
            <cfprocresult name="NewID" resultset="1">
            <cfprocresult name="ErrorCheck" resultset="2">
        </cfstoredproc>
        
        <cfset retVal = {} />
        <cfset retVal.NewID = NewID /> 
        <cfset retVal.ErrorCheck = ErrorCheck />

        <cfreturn retVal />
    </cffunction>
    <!--- Create Stored Procedure to create HR Record for employee --->
    
    
    
    
    
    <!--- Create Stored Procedure to create HR Record for employee --->
    <cffunction name="funcCreateEmployeeRehire" returntype="any">
    	<cfargument default="-1" name="QUERIES" required="yes"/>
        <cfargument default="-1" name="PASSEDIN" required="yes"/>
        <cfargument default="-1" name="FORM" required="yes"/>
        
        <cfif ARGUMENTS.QUERIES.GetEmpInfo.SalaryHourlyID EQ -10192>
			<cfset LOCAL.Exempt = -1>
        <cfelse>
            <cfset LOCAL.Exempt = 0>
        </cfif> 
        
        <cfif ARGUMENTS.QUERIES.GetEmpInfo.Seasonal>
			<cfset LOCAL.Seasonal = -1>
        <cfelse>
            <cfset LOCAL.Seasonal = 0>
        </cfif> 
        
        <cfif ARGUMENTS.QUERIES.GetEmpInfo.FullTime>
			<cfset LOCAL.FullTime = -1>
        <cfelse>
            <cfset LOCAL.FullTime = 0>
        </cfif>
        
        <cfset LOCAL.AnnualSalary = ARGUMENTS.QUERIES.GetEmpInfo.PayRate * ARGUMENTS.QUERIES.GetAF.AnnualizingFactor />
        
        <cfset LOCAL.HRSupID = SUPER.SCF_HR_MasterID_to_HRPersonID( ARGUMENTS.QUERIES.GetEmpInfo.SupervisorID ) />
        
        <cfstoredproc datasource="#Session.DataSource#" procedure="scf_SCFVM18_RehireStep1">  
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.CheckRehire.PersonIDNo#"><!---@pintPersonIDNo --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.PositionID#"><!---@pintPosID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PP_REHIRE#"><!---@pintPosStatusID --->
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.ActStartDate#"><!---@pdteHire --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#LOCAL.HRSupID#"><!---@pintHRSupID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PRIMARY_POS#"><!---@pintPrimaryPos --Always (-1) --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PROMOTION#"><!---@pintPromotion --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#LOCAL.Exempt#"><!---@pintExempt --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.SalaryHourlyID#"><!---@pintSalaryHourlyID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#LOCAL.Seasonal#"><!---@pintSeasonal      --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.HoursPerWeek#"><!---@pintHrsPerWk --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.WorkersCompID#"><!---@pintWrksCompID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.COMP_LOCATION_FACTOR#"><!---@pintCompLocFactor --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.PS_REHIRE#"><!---@pintPayStatusID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.CompTypeID#"><!---@pintCompTypeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.FrequencyID#"><!---@pintFreqID --->
            <cfprocparam cfsqltype="cf_sql_float" value="#ARGUMENTS.QUERIES.GetEmpInfo.PayRate#"><!---@pfltPayRate --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetAF.AnnualizingFactor#"><!---@pintAnnualizingFactor --->
            <cfprocparam cfsqltype="cf_sql_float" value="#LOCAL.AnnualSalary#"><!---@pfltAnnualSalary --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.BASEPAY#"><!---@pintBasePay --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.DOLLARS#"><!---@pintDollars --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ACTIVE#"><!---@pintActive --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.EmpCodeID#"><!---@pintEmploymentCodeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#LOCAL.FullTime#"><!---@pintFullTime --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.I9#"><!---@pintI9OnFileID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ORG_SCF#"><!---@pintOrgID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.ES_REHIRE#"><!---@pintESID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.PASSEDIN.REHIRE#"><!---@pintAction --->
            <cfprocparam cfsqltype="cf_sql_date" value="#ARGUMENTS.QUERIES.GetEmpInfo.DOB#"><!---@pdteDOB --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.First#"><!---@pstrFirst --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Last#"><!---@pstrLast --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.MaritalStatusID#"><!---@pintMaritalStatusID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.Middle#"><!---@pstrMiddle --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.PreferredName#"><!---@pstrPreferred --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.QUERIES.GetEmpInfo.EthnicID#"><!---@pintEthnicCodeID --->
            <cfprocparam cfsqltype="cf_sql_integer" value="#VAL(ARGUMENTS.QUERIES.GetEmpInfo.GenderID)#"><!---@pintGenderID --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.QUERIES.GetEmpInfo.SSN#"><!---@pstrSSN --->
            <cfprocparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.NewUserID#"><!---@pstrNewUserID --->
            <cfprocresult name="NewID" resultset="1">
            <cfprocresult name="ErrorCheck" resultset="2">
        </cfstoredproc> 
              
        <cfset retVal = {} />
        <cfset retVal.NewID = NewID /> 
        <cfset retVal.ErrorCheck = ErrorCheck />

        <cfreturn retVal />
    </cffunction>
    <!--- Create Stored Procedure to create HR Record for employee --->
    
    
    
    
    
    <!--- Test to see if person is a rehire--->
    <cffunction name="funcCheckRehire" returntype="any">
    	<cfargument default="-1" name="SSN"  required="yes"/>
        
        <cfquery name ="qryCheckRehire" datasource="#Session.DataSourceWFCDB#">
			SELECT 
            	PersonIDNo 
            FROM 
            	tPersons 
    		WHERE 
            	PersonTaxIDNo = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.SSN#" />
        </cfquery>
		
        <cfreturn qryCheckRehire />
    </cffunction>
    <!--- Test to see if person is a rehire--->
    
    
    
    
    
    <!--- UPDATE Primary Phones --->
    <cffunction name="funcUpdatePrimaryPhones" returntype="any">
    	<cfargument default="-1" name="PersonIDNo"  required="yes"/>
        <cfargument default="-1" name="DateOFHire"  required="yes"/>
        
        <cfquery name ="qryUpdateNextServer" datasource="#Session.DataSource#">

            scf_SCFVM18_PrimePhones #ARGUMENTS.PersonIDNo#, 
            '#dateformat(dateadd("d", -1, ARGUMENTS.DateOFHire),"mm/dd/yyyy")#'

        </cfquery>

    </cffunction>
    <!--- UPDATE Primary Phones --->
    
    
    
    
    
    <!--- UPDATE Next Mail Server--->
    <cffunction name="funcUpdateNextServer" returntype="any">
    	<cfargument default="-1" name="NextMailServerID"  required="yes"/>
        
        <cfquery name ="qryUpdateNextServer" datasource="#Session.DataSource#">
            Update 
            	NextMailServer 
    		Set 
            	ServerID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.NextMailServerID#" />
        </cfquery>

    </cffunction>
    <!--- UPDATE Next Mail Server--->
    
    
   
	
    <!--- UPDATE Step3 Employee--->
    <cffunction name="funcUpdateStep3Employee" returntype="any">
    	<cfargument default="" name="FORM"  required="yes"/>
        
        <cfset retObj = {} />
        
        <cfif !isDefined('ARGUMENTS.FORM.Decline')>
        
            <cfquery name="qryUpdateStep3Employee" datasource="#Session.DataSource#" >                    
                UPDATE 
                    Employee
                SET
                    DOB = <cfqueryparam cfsqltype="cf_sql_date" value="#ARGUMENTS.FORM.DOB#" />,
                    SSN = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.SSN#" />,
                    I9 = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.I9#" />,
                    MaritalStatusID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.MaritalStatusID#" />,
                    EthnicID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.EthnicID#" />,
                    GenderID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.GenderID#" />,
                    ActStartDate = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.DateOfHire#" />
                WHERE 
                    ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.EmpID#" />
                
            </cfquery>
            
            <!---TODO:  BAD!!!  I only doing this query block because I'm tired of trying--->
            <cfquery name="qryUpdateAction" datasource="#Session.DataSource#">
                Update 
                    StepActions
                Set  
                    Notes = <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Notes#" />
                Where 
                    ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.StepID#" />
            </cfquery>
        
        <cfelse>
        	<cfset SUPER.funcUpdateAction(ARGUMENTS.FORM.StepID, Session.intUserRosettaID, 'Orientation No Show - #ARGUMENTS.FORM.Notes#') />
        </cfif>
        
        <cfset retObj.FORM = ARGUMENTS.FORM />
        
    	<cfreturn retObj />
    </cffunction>
    <!--- UPDATE Step3 Employee  --->
    
    
    
    
    <!--- INSERT Rosetta Record--->
    <cffunction name="funcCreateRosettaRecord" returntype="any">
    	<cfargument default="" name="thread"  required="yes"/>  
        
        <cfquery name="qryCreateRosettaRecord" datasource="#Session.DataSourceRosetta#">                
			<!---scf_CreateRosettaRecord 
			<cfif thread.UserID EQ ''>NULL<cfelse>'#thread.UserID#'</cfif>, 
            <cfif thread.AD_GUID EQ ''>NULL<cfelse>'#thread.AD_GUID#'</cfif>, 
            <cfif thread.HRProdID EQ 0 or thread.HRProdID EQ ''>NULL<cfelse>#thread.HRProdID#</cfif>, 
            <cfif thread.EPAR_ID EQ 0 or thread.EPAR_ID EQ ''>NULL<cfelse>#thread.EPAR_ID#</cfif> - Scott's old stored procedure --->
            
            Insert into RosettaStone (
            	UserAccount, AD_GUID, HRProd_PersonIDNo, EPAR_ID, [Disabled]
            )
			Values (
            	<cfif ARGUMENTS.thread.UserID NEQ ''><cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.thread.UserID#" /><cfelse>NULL</cfif>, 
                <cfif ARGUMENTS.thread.AD_GUID NEQ ''><cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.thread.AD_GUID#" /><cfelse>NULL</cfif>, 
                <cfif ARGUMENTS.thread.HRProdID NEQ 0 OR ARGUMENTS.thread.HRProdID NEQ ''><cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.thread.HRProdID#" /><cfelse>NULL</cfif>, 
                <cfif ARGUMENTS.thread.EPAR_ID NEQ 0 OR ARGUMENTS.thread.EPAR_ID NEQ ''><cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.thread.EPAR_ID#" /><cfelse>NULL</cfif>, 
                1
            )
            
            SELECT @@Identity AS NewRosettaID
        </cfquery>
        
        <cfreturn qryCreateRosettaRecord />
    </cffunction>
    <!--- INSERT Rosetta Record--->
    
    
    
    
    <!--- INSERT Beneficaries Step3 Employee--->
    <cffunction name="funcStep3InsertBeneficaries" returntype="any">
    	<cfargument default="" name="FORM"  required="yes"/>
        
        <cfset retObj = {} />        
        
        <cfquery name="qryStep3InsertBeneficaries" datasource="#Session.DataSource#">                
            Insert Into Contacts 
            	(EmployeeID, First, Last, Address1, Address2, City, State, ZIP, HomePhone, CellPhone, WorkPhone, WorkPhoneExt, PhonePrimaryID, Email, RelationID, ContactTypeID)
            Values 
            (
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.EmpID#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.First#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Last#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Address1#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Address2#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.City#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.State#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.ZIP#" />,
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.HomePhone#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.CellPhone#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.WorkPhone#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.WorkPhoneExt#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.PhonePrimaryID#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Email#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.RelationID#" />,
                <cfqueryparam cfsqltype="cf_sql_integer" value="1" /> <!---1 Beneficiary, 2 Emergency Contact--->
             )
                
        </cfquery>
        
        <cfset retObj.FORM = ARGUMENTS.FORM />
        
    	<cfreturn retObj />
    </cffunction>
    <!--- INSERT Beneficaries Step3 Employee--->
    
    
    
    
    <!--- INSERT Emergency Contacts Step3 Employee--->
    <cffunction name="funcStep3InsertEmergencyContacts" returntype="any">
    	<cfargument default="" name="FORM"  required="yes"/>
        
        <cfset retObj = {} />        
        
        <cfquery name="qryStep3InsertEmergencyContacts" datasource="#Session.DataSource#">                
            Insert Into Contacts 
            	(EmployeeID, First, Last, Address1, Address2, City, State, ZIP, HomePhone, CellPhone, WorkPhone, WorkPhoneExt, PhonePrimaryID, Email, RelationID, ContactTypeID)
            Values 
            (
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.EmpID#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.First#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Last#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Address1#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Address2#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.City#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.State#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.ZIP#" />,
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.HomePhone#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.CellPhone#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.WorkPhone#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.WorkPhoneExt#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.PhonePrimaryID#" />, 
                <cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.FORM.Email#" />, 
                <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.FORM.RelationID#" />,
                <cfqueryparam cfsqltype="cf_sql_integer" value="2" /> <!---2 Beneficiary, 2 Emergency Contact--->
             )
                
        </cfquery>
        
        <cfset retObj.FORM = ARGUMENTS.FORM />
        
    	<cfreturn retObj />
    </cffunction>
    <!--- INSERT Emergency Contacts Step3 Employee--->
    
    

</cfcomponent>